const ActLocation = require('../model/actLocation.model')

class ActLocationService {
    /**
     * 新增签到地点
     */
    async addLocation (locationData) {
        // 插入数据
        try {
            const res = await ActLocation.create(locationData)
            return res
        } catch (error) {
            return {
                errorFlag: 'error',
                message: error,
            }
        }
    }
    /**
         * 修改定位信息
         */
    async modifyLocationByActId (modifyData, act_id) {
        try {
            const res = await ActLocation.update(modifyData, { where: { act_id } })
            return res
        } catch (error) {
            return {
                errorFlag: 'error',
                message: error,
            }
        }
    }

    /**
     * 查找活动是否已经标记签到地点
     */
    async getActLoaction (act_id) {
        const res = await ActLocation.findOne({ where: { act_id } })
        return res
    }
}

module.exports = new ActLocationService()